#ifndef __SPDF_OPT_H__
#define __SPDF_OPT_H__

#include "stdint.h"
#include "stdlib.h"
#include "mytype.h"

#ifdef __cplusplus
extern "C"
{
#endif

#define spdf_sprintf sprintf

#define SPDF_FONT_COURIER "Courier"
#define SPDF_FONT_COURIER_BOLD "Courier-Bold"
#define SPDF_FONT_COURIER_OBLIQUE "Courier-Oblique"
#define SPDF_FONT_COURIER_BOLD_OBLIQUE "Courier-BoldOblique"
#define SPDF_FONT_HELVETICA "Helvetica"
#define SPDF_FONT_HELVETICA_BOLD "Helvetica-Bold"
#define SPDF_FONT_HELVETICA_OBLIQUE "Helvetica-Oblique"
#define SPDF_FONT_HELVETICA_BOLD_OBLIQUE "Helvetica-BoldOblique"
#define SPDF_FONT_TIMES_ROMAN "Times-Roman"
#define SPDF_FONT_TIMES_BOLD "Times-Bold"
#define SPDF_FONT_TIMES_ITALIC "Times-Italic"
#define SPDF_FONT_TIMES_BOLD_ITALIC "Times-BoldItalic"
#define SPDF_FONT_SYMBOL "Symbol"
#define SPDF_FONT_ZAPF_DINGBATS "ZapfDingbats"

#define SPDF_FONT_Sun "SimSun"
#define SPDF_FONT_Sun_B "SimSun-Blod"
#define SPDF_FONT_Hei "SimHei"
#define SPDF_FONT_Hei_B "SimHei-Blod"
#define SPDF_FONT_Sun_I "SimSun-Italic"
#define SPDF_FONT_Sun_IB "SimSun-BoldItalic"
#define SPDF_FONT_Hei_I "SimHei-Italic"
#define SPDF_FONT_Hei_IB "SimHei-BoldItalic"

#define SPDF_FONT_ID_COURIER 0x0000
#define SPDF_FONT_ID_COURIER_B 0x0001
#define SPDF_FONT_ID_COURIER_O 0x0002
#define SPDF_FONT_ID_COURIER_OB 0x0003
#define SPDF_FONT_ID_HELVETICA 0x0004
#define SPDF_FONT_ID_HELVETICA_B 0x0005
#define SPDF_FONT_ID_HELVETICA_O 0x0006
#define SPDF_FONT_ID_HELVETICA_BO 0x0007
#define SPDF_FONT_ID_TIMES_R 0x0008
#define SPDF_FONT_ID_TIMES_B 0x0009
#define SPDF_FONT_ID_TIMES_I 0x000A
#define SPDF_FONT_ID_TIMES_BI 0x000B
#define SPDF_FONT_ID_SYMBOL 0x000C
#define SPDF_FONT_ID_ZAP 0x000D

#define SPDF_FONT_ID_INVALID 0x00FF

#define SPDF_FONT_ID_Sun 100
#define SPDF_FONT_ID_Sun_B 101
#define SPDF_FONT_ID_Hei 102
#define SPDF_FONT_ID_Hei_B 103
#define SPDF_FONT_ID_Sun_I 104
#define SPDF_FONT_ID_Sun_IB 105
#define SPDF_FONT_ID_Hei_I 106
#define SPDF_FONT_ID_Hei_IB 107

#define SPDF_OK 0
#define SPDF_FAILED 1
#define SPDF_TRUE 1
#define SPDF_FALSE 0
#define SPDF_NOERROR 0

#define SPDF_INVALID_OBJECT 0x1033
#define SPDF_INVALID_IMAGE 0x1030
#define SPDF_INVALID_COLOR_SPACE 0x1020
#define SPDF_INVALID_IMAGE_WIDTH 0x1031
#define SPDF_PAGE_INVALID_SIZE 0x1054
#define SPDF_INVALID_DOCUMENT 0x1025
#define SPDF_PAGE_INVALID_FONT 0x104F

#define SPDF_GMODE_PAGE_DESCRIPTION 0x0001
#define SPDF_GMODE_PATH_OBJECT 0x0002
#define SPDF_GMODE_TEXT_OBJECT 0x0004
#define SPDF_GMODE_CLIPPING_PATH 0x0008
#define SPDF_GMODE_SHADING 0x0010
#define SPDF_GMODE_INLINE_IMAGE 0x0020
#define SPDF_GMODE_EXTERNAL_OBJECT 0x0040
#define SPDF_GMODE_INVALID 0x0080
#define SPDF_GMODE_OVER 0x0100

#define SPDF_ENCODING_ASCII 0
#define SPDF_ENCODING_UNICODE 1
#define SPDF_ENCODING_UTF8 2
#define SPDF_ENCODING_GBK 3

	typedef enum
	{
		SPDF_CS_DEVICE_GRAY = 0,
		SPDF_CS_DEVICE_RGB,
		SPDF_CS_DEVICE_CMYK,
		SPDF_CS_CAL_GRAY,
		SPDF_CS_CAL_RGB,
		SPDF_CS_LAB,
		SPDF_CS_ICC_BASED,
		SPDF_CS_SEPARATION,
		SPDF_CS_DEVICE_N,
		SPDF_CS_INDEXED,
		SPDF_CS_PATTERN,
		SPDF_CS_EOF
	} SPDF_ColorSpace;

	typedef enum
	{
		SPDF_OBJ_INFO = 0,
		SPDF_OBJ_STREAM,
		SPDF_OBJ_FONT,
		SPDF_OBJ_PAGE,
		SPDF_OBJ_CATALOG,
		SPDF_OBJ_PAGES,
		SPDF_OBJ_IMAGE,
		SPDF_OBJ_OUTLINE,
		SPDF_OBJ_OUTLINE_DES,
		SPDF_OBJ_EOF
	} SPDF_ObjType;

	typedef enum
	{
		SPDF_PAGE_HEIGHT = 0,
		SPDF_PAGE_WIDTH,
		SPDF_PAGE_CTX_LENGTH,
		SPDF_PAGE_GMODE,
		SPDF_PAGE_FONTUSED,
		SPDF_PAGE_FONTSIZE,
		SPDF_PAGE_TXT_X_ZOOM,
		SPDF_PAGE_TXT_Y_ZOOM,
		SPDF_PAGE_EOF
	} SPDF_PageAttr;

	typedef enum
	{
		SPDF_IMAGE_HEIGHT = 0,
		SPDF_IMAGE_WIDTH,
		SPDF_IMAGE_BITS,
		SPDF_IMAGE_COLORSPACE,
		SPDF_IMAGE_LENGTH,
		SPDF_IMAGE_ADDR,
		SPDF_IMAGE_OWNER,
		SPDF_IMAGE_NUMBER,
		SPDF_IMAGE_EOF
	} SPDF_ImageAttr;

	typedef struct
	{
		SPDF_ObjType type;
		uu16 offset;
		uu16 number;
		int attr[10];
		void *doc;
	} SPDF_Obj;

	typedef struct
	{
		char title[32];			  
		uu08 level;				  
		uu08 encoding;			  
		ii16 obj_num;			  
		ii16 parent;			  
		uu16 page_obj_site, x, y; 
	} SPDF_outline_obj_type;

	typedef struct
	{
		SPDF_outline_obj_type *list;
		ii16 list_len;
		ii16 list_used_num;
	} SPDF_outline_type;

	typedef struct
	{
		SPDF_Obj *obj;
		int offset;
		uu16 page_info_obj_num;
		uu16 obj_num;
		uu16 img_num;
		uu16 obj_len_max;
		uu32 error;

		char buf[512];
		char font_cns_amount;
        uu16 chk_err_cnt;
        
		struct
		{
			uint16_t file_buff_index;
			uint16_t file_buff_size;
			uint8_t *file_buff;
			int (*file_disk_out)(uint8_t *buff, int len);
		} fil;

		SPDF_outline_type outline;
	} SPDF_Doc_Rec;

	typedef struct
	{
		ii32 x, y;
		uu8 ipn;
	} SPDF_pos_type;

	typedef struct
	{
		ii32 x, y, w, h;
		uu8 ipn;
	} SPDF_rect_type;

	typedef struct
	{
		uint16_t cp_char;
		uint16_t unicode;
		uint16_t width;
	} SPDF_font_wide_type;

	typedef SPDF_Doc_Rec *SPDF_Doc;
	typedef SPDF_Obj *SPDF_Page;
	typedef SPDF_Obj *SPDF_Image;
	extern const char *font_list[];

	const char *spdf_get_version(void);

	SPDF_Doc spdf_init(SPDF_Doc pdf, SPDF_Obj *pdf_obj, uu16 obj_len);

	void spdf_disk_out_link(SPDF_Doc pdf, int (*disk_out)(uint8_t *buff, int len));
	void spdf_disk_buff_set(SPDF_Doc pdf, uint8_t *buff, int len); 
	void spdf_font_cns_open(SPDF_Doc pdf_doc, char amount);		   
	SPDF_Doc spdf_create(SPDF_Doc pdf_doc);						   
	ii16 spdf_obj_space_remain(SPDF_Doc pdf);					   

	void spdf_outline_init(SPDF_Doc pdf, SPDF_outline_obj_type *list, ii16 len);

	ii16 spdf_outline_add(SPDF_Doc pdf, uu08 level, SPDF_Page page, uu16 x, uu16 y, const char *title, uu08 encoding);
	
#define spdf_bookmark_add(level, x, y, t, e) spdf_outline_add(pdf, level, page, x, y, t, e)

	ii16 spdf_outline_space_remain(SPDF_Doc pdf);
#define spdf_bookmark_space_remain() spdf_outline_space_remain(pdf)

	void spdf_custom(SPDF_Page page, const char *cmd);

	void spdf_custom_with_par(
		SPDF_Page page, const char *cmd,
		ii32 par,
		uu8 ip_n);

	void spdf_custom_with_par2(
		SPDF_Page page, const char *cmd,
		ii32 par1, ii32 par2,
		uu8 ip_n);

	void spdf_custom_with_par3(
		SPDF_Page page, const char *cmd,
		ii32 par1, ii32 par2, ii32 par3,
		uu8 ip_n);

	void spdf_custom_with_multi_par(
		SPDF_Page page, const char *cmd,
		ii32 *par, uu8 par_num,
		uu8 ip_n);

#define SPDF_CMD_NoExe 0x01
#define SPDF_CMD_End 0x02
#define SPDF_CMD_NoNum 0x10
#define SPDF_CMD_TFore 0x20
	typedef struct
	{
		const char *text;
		ii16 val;
		uu8 ip_n;
		
		uu8 attr;
	} spdf_custom_par_type;

	void spdf_custom_cfg(
		spdf_custom_par_type *par,
		const char *text,
		ii16 val,
		uu8 ip_n,
		uu8 attr);

	void spdf_custom_exe(SPDF_Page page, spdf_custom_par_type *par, ii8 max);

	ii8 spdf_has_doc(SPDF_Doc pdf);

	SPDF_Page spdf_add_page(SPDF_Doc pdf);

	uu32 spdf_save(SPDF_Doc pdf, const char *file_name);

	uu32 spdf_page_check(SPDF_Page page, uu32 mode);

	uu32 spdf_page_save(SPDF_Page page);

	uu16 spdf_page_get_height(SPDF_Page page);

	uu16 spdf_page_get_width(SPDF_Page page);

	uu32 spdf_page_set_height(SPDF_Page page, uu16 value);

	uu32 spdf_page_set_width(SPDF_Page page, uu16 value);

	uu32 spdf_page_push(SPDF_Page page);
	uu32 spdf_page_pop(SPDF_Page page);
#define spdf_push() spdf_page_push(page)
#define spdf_pop() spdf_page_pop(page)

	uu32 spdf_page_font_set(SPDF_Page page, const char *font_name, uu16 size);
#define spdf_font_set(name, size) spdf_page_font_set(page, name, size)

	uu32 spdf_page_font_iset(SPDF_Page page, char index, uu16 size);
#define spdf_font_iset(n, size) spdf_page_font_iset(page, n, size)

	const char *spdf_font_name_get(char type, char index);

	uu32 spdf_page_text_begin(SPDF_Page page);
#define spdf_text_begin() spdf_page_text_begin(page)

	uu32 spdf_page_text_end(SPDF_Page page);
#define spdf_text_end() spdf_page_text_end(page)

	uu32 spdf_page_color_fill_rgb_set(SPDF_Page page, uu8 r, uu8 g, uu8 b);
#define spdf_color_fill_rgb(r, g, b) spdf_page_color_fill_rgb_set(page, r, g, b)

	uu32 spdf_page_color_fill_rgb8_set(SPDF_Page page, uu8 r, uu8 g, uu8 b);
#define spdf_color_fill_rgb8(r, g, b) spdf_page_color_fill_rgb8_set(page, r, g, b)

	uu32 spdf_page_color_fill_cmyk_set(SPDF_Page page, uu8 c, uu8 m, uu8 y, uu8 k);
#define spdf_color_fill_cmyk(c, m, y, k) spdf_page_color_fill_cmyk_set(page, c, m, y, k)

	uu32 spdf_page_color_fill_gray_set(SPDF_Page page, uu8 gray);
#define spdf_color_fill_gray(g) spdf_page_color_fill_gray_set(page, g)

	uu32 spdf_page_text_char_space_set(SPDF_Page page, ii32 space);
#define spdf_text_char_space(s) spdf_page_text_char_space_set(page, s)

	uu32 spdf_page_text_word_space_set(SPDF_Page page, ii32 space);
#define spdf_text_word_space(s) spdf_page_text_word_space_set(page, s)

	uu32 spdf_page_text_line_space_set(SPDF_Page page, ii32 space);
#define spdf_text_line_space(s) spdf_page_text_line_space_set(page, s)

	uu32 spdf_page_text_x_zoom_set(SPDF_Page page, ii32 per);
#define spdf_text_x_zoom(z) spdf_page_text_x_zoom_set(page, z)

	uu32 spdf_page_text_rise_set(SPDF_Page page, ii16 dy, uu08 pn);
#define spdf_text_rise(r, pn) spdf_page_text_rise_set(page, r, pn)

	uu32 spdf_page_text_matrix_set(
		SPDF_Page page,
		ii32 a, ii32 b, ii32 c, ii32 d, ii32 x, ii32 y, uu8 xypn);
#define spdf_text_matrix(a, b, c, d, x, y, pn) spdf_page_text_matrix_set(page, a, b, c, d, x, y, pn)

	uu32 spdf_page_text_matrix_zoom(SPDF_Page page, ii16 x_zoom, ii16 y_zoom, ii32 x, ii32 y, uu8 xypn);
#define spdf_text_matrix_zoom(x_z, y_z, x, y, xypn) spdf_page_text_matrix_zoom(page, x_z, y_z, x, y, xypn)

	uu32 spdf_page_text_matrix_rotating_p(SPDF_Page page, ii32 x, ii32 y, uu8 xypn, ii16 angle_0_359); 
	uu32 spdf_page_text_matrix_rotating_n(SPDF_Page page, ii32 x, ii32 y, uu8 xypn, ii16 angle_0_359); 
#define spdf_page_text_matrix_rotating spdf_page_text_matrix_rotating_n
#define spdf_text_matrix_rot_p(x, y, pn, alg) spdf_page_text_matrix_rotating_p(page, x, y, pn, alg)
#define spdf_text_matrix_rot_n(x, y, pn, alg) spdf_page_text_matrix_rotating_n(page, x, y, pn, alg)
#define spdf_text_matrix_rot(x, y, pn, alg) spdf_page_text_matrix_rotating_n(page, x, y, pn, alg)

	uu32 spdf_page_text_matrix_rotating_mirror_p(SPDF_Page page, ii32 x, ii32 y, uu8 xypn, ii16 angle_0_359); 
	uu32 spdf_page_text_matrix_rotating_mirror_n(SPDF_Page page, ii32 x, ii32 y, uu8 xypn, ii16 angle_0_359); 
#define spdf_text_matrix_mirror_rot_p(x, y, pn, alg) spdf_page_text_matrix_rotating_mirror_p(page, x, y, pn, alg)
#define spdf_text_matrix_mirror_rot_n(x, y, pn, alg) spdf_page_text_matrix_rotating_mirror_n(page, x, y, pn, alg)

	uu32 spdf_page_text_matrix_skew_nor(SPDF_Page page, ii32 x, ii32 y, uu8 xypn, ii16 z, ii16 r);
	
	uu32 spdf_page_text_matrix_skew_mirror(SPDF_Page page, ii32 x, ii32 y, uu8 xypn, ii16 z, ii16 r);
#define spdf_text_matrix_skew_nor(x, y, pn, z, r) spdf_page_text_matrix_skew_nor(page, x, y, pn, z, r)
#define spdf_text_matrix_skew_mirror(x, y, pn, z, r) spdf_page_text_matrix_skew_mirror(page, x, y, pn, z, r)

	uu32 spdf_page_text_mode_set(SPDF_Page page, uu8 mode, uu16 wide);
#define spdf_text_mode(m, w) spdf_page_text_mode_set(page, m, w)

	uu32 spdf_page_text_show(SPDF_Page page, const char *text);
#define spdf_text_show(t) spdf_page_text_show(page, t)

	uu32 spdf_page_text_rotating_show(SPDF_Page page, ii32 x, ii32 y, uu8 xypn, ii16 angle_0_359, const char *text);
#define spdf_text_rot_show(x, y, pn, a, t) spdf_page_text_rotating_show(page, x, y, pn, a, t)

	uu32 spdf_page_text_show_check(SPDF_Page page);
#define spdf_text_show_check() spdf_page_text_show_check(page)

	uu32 spdf_page_text_ascii_show(SPDF_Page page, const char *text);
#define spdf_text_ascii_show(t) spdf_page_text_ascii_show(page, t)

	uu32 spdf_page_text_gbk_show(SPDF_Page page, const char *text);
#define spdf_text_gbk_show(t) spdf_page_text_gbk_show(page, t)

	uu32 spdf_page_text_move(SPDF_Page page, ii32 dx, ii32 dy);
#define spdf_text_move(x, y) spdf_page_text_move(page, x, y)

	uu32 spdf_page_text_move_p1(SPDF_Page page, ii32 dx, ii32 dy);
#define spdf_text_move_p1(x, y) spdf_page_text_move_p1(page, x, y)

	uu32 spdf_page_text_move_to_next_line(SPDF_Page page);
#define spdf_text_next_line() spdf_page_text_move_to_next_line(page)

	uu32 spdf_page_text_move_show(
		SPDF_Page page,
		uu16 dx, uu16 dy,
		const char *text);

#define spdf_text_move_show(x, y, t) spdf_page_text_move_show(page, x, y, t)

#define spdf_page_text_next_line_show(page, text) \
	do                                            \
	{                                             \
		spdf_page_text_move_to_next_line(page);   \
		spdf_page_text_show(page, text);          \
	} while (0)

#define spdf_text_next_line_show(t) spdf_page_text_next_line_show(page, t)

	uu32 spdf_page_color_line_rgb_set(SPDF_Page page, uu8 r, uu8 g, uu8 b);
#define spdf_color_line_rgb(r, g, b) spdf_page_color_line_rgb_set(page, r, g, b)

	uu32 spdf_page_color_line_rgb8_set(SPDF_Page page, uu8 r, uu8 g, uu8 b);
#define spdf_color_line_rgb8(r, g, b) spdf_page_color_line_rgb8_set(page, r, g, b)

	uu32 spdf_page_color_line_cmyk_set(
		SPDF_Page page,
		uu8 c, uu8 m, uu8 y, uu8 k);
#define spdf_color_line_cmyk(c, m, y, k) spdf_page_color_line_cmyk_set(page, c, m, y, k)

	uu32 spdf_page_color_line_gray_set(SPDF_Page page, uu8 gray);
#define spdf_color_line_gray(g) spdf_page_color_line_gray_set(page, g)

	uu32 spdf_page_line_dash_off(SPDF_Page page);
	uu32 spdf_page_line_dash_on(SPDF_Page page, ii16 on, ii16 off, uu8 ip_n);
#define spdf_line_dash_off() spdf_page_line_dash_off(page)
#define spdf_line_dash_on(on, off, pn) spdf_page_line_dash_on(page, on, off, pn)

	uu32 spdf_page_line_end_mode(SPDF_Page page, uu8 mode);	 
	uu32 spdf_page_line_node_mode(SPDF_Page page, uu8 mode); 
#define spdf_line_end_mode(m) spdf_page_line_end_mode(page, m)
#define spdf_line_node_mode(m) spdf_page_line_node_mode(page, m)

	uu32 spdf_page_line_width_set(SPDF_Page page, uu16 line_width);
#define spdf_line_width(w) spdf_page_line_width_set(page, w)

	uu32 spdf_page_stroke(SPDF_Page page);
#define spdf_stroke() spdf_page_stroke(page)

	uu32 spdf_page_stroke_fill(SPDF_Page page);
#define spdf_stroke_fill() spdf_page_stroke_fill(page)

	uu32 spdf_page_stroke_line_fill(SPDF_Page page);
#define spdf_stroke_line_fill() spdf_page_stroke_line_fill(page)

	uu32 spdf_page_stroke_close(SPDF_Page page);
#define spdf_stroke_close() spdf_page_stroke_close(page)

	uu32 spdf_page_stroke_close_fill(SPDF_Page page);
#define spdf_stroke_close_fill() spdf_page_stroke_close_fill(page)

	uu32 spdf_page_line_move_to(SPDF_Page page, ii32 x, ii32 y, uu8 ip_n);
#define spdf_line_move_to(x, y, ip_n) spdf_page_line_move_to(page, x, y, ip_n)

	uu32 spdf_page_line_move_to_p1(SPDF_Page page, ii32 x, ii32 y);
#define spdf_line_move_to_p1(x, y) spdf_line_move_to_p1(page, x, y)

	uu32 spdf_page_line_to(SPDF_Page page, ii32 x, ii32 y, uu8 ip_n);
#define spdf_line_to(x, y, ip_n) spdf_page_line_to(page, x, y, ip_n)

#define spdf_page_line_cross_stroke(pg, cx, cy, len, ip_n) \
	do                                                     \
	{                                                      \
		spdf_page_line_move_to(pg, cx - len, cy, ip_n);    \
		spdf_page_line_to(pg, cx + len, cy, ip_n);         \
		spdf_page_stroke(pg);                              \
		spdf_page_line_move_to(pg, cx, cy - len, ip_n);    \
		spdf_page_line_to(pg, cx, cy + len, ip_n);         \
		spdf_page_stroke(pg);                              \
	} while (0)
#define spdf_line_cross_stroke(cx, cy, len, ip_n) spdf_page_line_cross_stroke(page, cx, cy, len, ip_n)

#define spdf_page_line_xcross_stroke(pg, cx, cy, len, ip_n)                             \
	do                                                                                  \
	{                                                                                   \
		spdf_page_line_move_to(pg, cx - len * 707 / 1000, cy - len * 707 / 1000, ip_n); \
		spdf_page_line_to(pg, cx + len * 707 / 1000, cy + len * 707 / 1000, ip_n);      \
		spdf_page_stroke(pg);                                                           \
		spdf_page_line_move_to(pg, cx + len * 707 / 1000, cy - len * 707 / 1000, ip_n); \
		spdf_page_line_to(pg, cx - len * 707 / 1000, cy + len * 707 / 1000, ip_n);      \
		spdf_page_stroke(pg);                                                           \
	} while (0)
#define spdf_line_xcross_stroke(cx, cy, len, ip_n) spdf_page_line_xcross_stroke(page, cx, cy, len, ip_n)

#define spdf_page_line_cross_c_stroke(pg, cx, cy, len, c, ip_n) \
	do                                                          \
	{                                                           \
		spdf_page_line_cross_stroke(pg, cx, cy, len, ip_n);     \
		if (c > 3)                                              \
		{                                                       \
			spdf_page_cycle(pg, cx, cy, c, ip_n);               \
			spdf_page_stroke(pg);                               \
		}                                                       \
	} while (0)
#define spdf_line_cross_c_stroke(cx, cy, len, c, ip_n) spdf_page_line_cross_c_stroke(page, cx, cy, len, c, ip_n)

#define spdf_page_line_xcross_c_stroke(pg, cx, cy, len, c, ip_n) \
	do                                                           \
	{                                                            \
		spdf_page_line_xcross_stroke(pg, cx, cy, len, ip_n);     \
		if (c > 3)                                               \
		{                                                        \
			spdf_page_cycle(pg, cx, cy, c, ip_n);                \
			spdf_page_stroke(pg);                                \
		}                                                        \
	} while (0)
#define spdf_line_xcross_c_stroke(cx, cy, len, c, ip_n) spdf_page_line_xcross_c_stroke(page, cx, cy, len, c, ip_n)

	uu32 spdf_page_line_to_p1(SPDF_Page page, ii32 x, ii32 y);
#define spdf_line_to_p1(x, y) spdf_page_line_to_p1(page, x, y)

	uu32 spdf_page_curve123_to(
		SPDF_Page page,
		ii32 x1, ii32 y1,
		ii32 x2, ii32 y2,
		ii32 x3, ii32 y3,
		uu8 ip_n);

	uu32 spdf_page_curve23_to(
		SPDF_Page page,
		ii32 x2, ii32 y2,
		ii32 x3, ii32 y3,
		uu8 ip_n);

	uu32 spdf_page_curve13_to(
		SPDF_Page page,
		ii32 x1, ii32 y1,
		ii32 x3, ii32 y3,
		uu8 ip_n);

	uu32 spdf_page_cycle(
		SPDF_Page page,
		ii32 x, ii32 y,
		ii32 c,
		uu8 ip_n);
#define spdf_cycle(x, y, c, pn) spdf_page_cycle(page, x, y, c, pn)

	uu32 spdf_page_ellipse(
		SPDF_Page page,
		ii32 x, ii32 y,
		ii32 cx, ii32 cy,
		uu8 ip_n);
#define spdf_ellipse(x, y, cx, cy, pn) spdf_page_ellipse(page, x, y, cx, cy, pn)

	uu32 spdf_page_q_cycle(SPDF_Page page, ii32 x, ii32 y, ii32 ray, uu08 ipn);

	uu32 spdf_page_q_ellipse(
		SPDF_Page page,
		ii32 x, ii32 y,
		ii32 xray, ii32 yray, uu08 ip_n);

	uu32 spdf_page_arc(
		SPDF_Page page,
		ii32 x,
		ii32 y,
		ii32 ray,
		uu08 ipn,
		ii32 ang1,
		ii32 ang2);

	uu32 spdf_page_rectangle(
		SPDF_Page page,
		ii32 x, ii32 y,
		ii32 width, ii32 height,
		uu8 ip_n);
#define spdf_rectangle(x, y, cx, cy, pn) spdf_page_rectangle(page, x, y, cx, cy, pn)

	uu32 spdf_page_draw_img(
		SPDF_Page page,
		SPDF_Image image,
		uu16 x, uu16 y,
		uu16 width, uu16 height);

	SPDF_Image spdf_page_draw_img_from_file(
		SPDF_Doc pdf,
		const char *filename,
		uu32 width, uu32 height,
		SPDF_ColorSpace color_space);

	SPDF_Image spdf_page_draw_img_from_mem(
		SPDF_Doc pdf,
		const uu8 *buf,
		uu32 width, uu32 height,
		SPDF_ColorSpace color_space,
		uu32 bits_per_component);

	uu8 spdf_rgb_to_gray(uu8 r, uu8 g, uu8 b);

	uu8 spdf_gry_to_rgb(uu8 *rgb, uu8 gray);

	ii32 spdf_base_font_id_ch_wide(ii16 font_id, ii16 ch, ii16 font_size);
	ii32 spdf_base_fond_ch_wide(const char *font, ii16 ch, ii16 font_size);
	ii32 spdf_base_font_id_str_wide(ii16 font_id, const char *str, ii16 font_size);
	ii32 spdf_base_font_str_wide(const char *font, const char *str, ii16 font_size);

	ii32 spdf_Courier_str_wide(const char *str, ii16 font_size);
	ii32 spdf_Courier_B_str_wide(const char *str, ii16 font_size);
	ii32 spdf_Courier_O_str_wide(const char *str, ii16 font_size);
	ii32 spdf_Courier_OB_str_wide(const char *str, ii16 font_size);
	ii32 spdf_Helvetica_str_wide(const char *str, ii16 font_size);
	ii32 spdf_Helvetica_B_str_wide(const char *str, ii16 font_size);
	ii32 spdf_Helvetica_O_str_wide(const char *str, ii16 font_size);
	ii32 spdf_Helvetica_OB_str_wide(const char *str, ii16 font_size);
	ii32 spdf_Times_str_wide(const char *str, ii16 font_size);
	ii32 spdf_Times_B_str_wide(const char *str, ii16 font_size);
	ii32 spdf_Times_I_str_wide(const char *str, ii16 font_size);
	ii32 spdf_Times_BI_str_wide(const char *str, ii16 font_size);
	ii32 spdf_half_font_str_wide(const char *str, ii16 font_size);

#ifdef __cplusplus
}
#endif

#endif
